/*
 * Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
 */

package com.xci.edu.core.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.github.lvyanyang.core.BaseEntity;
import com.github.lvyanyang.core.Const;
import com.github.lvyanyang.core.XCI;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 培训科目信息
 * @author 张谦 zhangqian@xci96716.com
 * @since 2020-11-24 17:54:07
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "培训科目信息")
public class EduCategory extends BaseEntity {
    /**
     * 主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @ExcelIgnore
    @Excel(name = "主键", width = 20d)
    @ApiModelProperty(value = "主键", position = 1)
    private Long id;

    /**
     * 科目名称
     */
    @NotBlank(message = "科目名称不能为空")
    @Length(max = 50, message = "科目名称长度不能超过{max}个字符")
    @Excel(name = "科目名称", width = 20d)
    @ApiModelProperty(value = "科目名称", required = true, position = 2)
    private String name;

    /**
     * 培训总学时(秒)
     */
    @NotNull(message = "培训总学时(秒)不能为空")
    @Excel(name = "培训总学时(秒)", width = 20d)
    @ApiModelProperty(value = "培训总学时(秒)", required = true, position = 3)
    private Integer totalPeriod;

    /**
     * 每日最大培训学时(秒)
     */
    @NotNull(message = "每日最大培训学时(秒)不能为空")
    @Excel(name = "每日最大培训学时(秒)", width = 20d)
    @ApiModelProperty(value = "每日最大培训学时(秒)", required = true, position = 4)
    private Integer dayMaxPeriod;

    /**
     * 验证问题允许尝试最大次数
     */
    @NotNull(message = "验证问题允许尝试最大次数不能为空")
    @Excel(name = "验证问题允许尝试最大次数", width = 20d)
    @ApiModelProperty(value = "验证问题允许尝试最大次数", required = true, position = 5)
    private Integer validateTryTime;

    /**
     * 验证问题回答超时时间(秒)
     */
    @NotNull(message = "验证问题回答超时时间(秒)不能为空")
    @Excel(name = "验证问题回答超时时间(秒)", width = 20d)
    @ApiModelProperty(value = "验证问题回答超时时间(秒)", required = true, position = 6)
    private Integer validateTimeout;

    /**
     * 验证问题随机弹出时间范围,格式:开始秒杀-结束秒数,如:900-1200
     */
    @NotBlank(message = "验证问题随机弹出时间范围,格式:开始秒杀-结束秒数,如:900-1200不能为空")
    @Length(max = 50, message = "验证问题随机弹出时间范围,格式:开始秒杀-结束秒数,如:900-1200长度不能超过{max}个字符")
    @Excel(name = "验证问题随机弹出时间范围", width = 20d)
    @ApiModelProperty(value = "验证问题随机弹出时间范围,格式:开始秒杀-结束秒数,如:900-1200", required = true, position = 7)
    private String validateRandomRange;

    /**
     * 状态[1-启用, 0-禁用]
     */
    @Excel(name = "状态", width = 20d, replace = { "启用_1", "禁用_0" })
    @ApiModelProperty(value = "状态[1-启用, 0-禁用]", required = true, position = 11)
    private Integer status;


    /**
     * 状态文本
     */
    @ApiModelProperty(value = "状态文本", position = 12)
    private String statusText;

    /**
     * 状态文本
     */
    public String getStatusText() {
        if(XCI.isEmpty(status)){
            return Const.Empty;
        }
        switch (status) {
            case 0:
                return "禁用";
            case 1:
                return "启用";
        }
        return Const.Empty;
    }

    /**
     * 备注
     */
    @Length(max = 500, message = "备注长度不能超过{max}个字符")
    @Excel(name = "备注", width = 20d)
    @ApiModelProperty(value = "备注", position = 8)
    private String remark;

}